<template>
  <div class="bgImg">
    <el-form :rules="rules" class="login-container" label-position="left" :model="loginForm"
             label-width="0px" v-loading="loading">
      <h3 class="login_title">高校公寓安检平台</h3>
      <el-form-item prop="uName">
        <el-input type="text" v-model="loginForm.uName" auto-complete="off" placeholder="用户名"></el-input>
      </el-form-item>
      <el-form-item prop="uName">
        <el-input type="text" v-model="loginForm.name" auto-complete="off" placeholder="真实姓名"></el-input>
      </el-form-item>
      <el-form-item prop="password">
        <el-input type="password" v-model="loginForm.password" uto-complete="off" placeholder="密码"
                  @keyup.enter.native="submitClick"></el-input>
      </el-form-item>
      <el-form-item style="width: 100%">
        <el-button type="primary" style="width: 75%" @click="register">注册</el-button>
      </el-form-item>
      <el-form-item>
        <router-link to='/' style="text-decoration: none;">返回登录</router-link>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
    export default {
        data() {
            return {
                rules: {
                    uName: [{required: true, message: '请输入用户名', trigger: 'blur'}],
                    name: [{required: true, message: '请输入真实姓名', trigger: 'blur'}],
                    password: [{required: true, message: '请输入密码', trigger: 'blur'}]

                },
                checked: true,
                loginForm: {
                    uName: '',
                    name:'',
                    password: ''

                },
                loading: false
            }
        },
        methods: {
            register() {
                var _this = this;
                this.loading = true;
                this.postRequest('/system/user/reg', {
                    uName: this.loginForm.uName,
                    name: this.loginForm.name,
                    password: this.loginForm.password
                }).then(resp => {
                    _this.loading = false;
                    if (resp && resp.status == 200) {
                        Message.success({message: resp.data.msg});
                        var path = _this.$route.query.redirect;
                        _this.$router
                            .replace({path: path == '/' || path == undefined ? '/login' : path});
                    }
                });
            },
        }
    }
</script>
<style>
  .bgImg {
    background: url("../assets/bgImg.jpg") center center no-repeat;
    background-size: 100% 100%;
    position: fixed;
    height: 100%;
    width: 100%;
    /* background-color: pink; */
  }

  .login-container {
    border-radius: 20px;
    background-clip: padding-box;
    margin: 180px auto;
    width: 420px;
    padding: 35px 35px 15px 35px;
    background: #fff;
    border: 2px solid #eaeaea;
    box-shadow: 0 0 25px #cac6c6;
  }

  .login_title {
    margin: 0px auto 40px auto;
    text-align: center;
    color: #505458;
  }
</style>
